﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using MyRoguelike.Game.Objects;

namespace MyRoguelike.GUI
{
    class GUIHealthBar
    {
        // Background texture
        private Texture2D _texBack;

        // Foreground texture
        private Texture2D _texForeg;

        // Player
        private GOPlayer _player;

        // Background texture
        public Texture2D Background
        {
            get { return _texBack; }
        }

        // Foreground texture
        public Texture2D Foreground
        {
            get { return _texForeg; }
        }

        // Bar position
        public Vector2 Position { get; set; }

        public GUIHealthBar(Texture2D texBack, Texture2D texForeg, GOPlayer player)
        {
            _texBack = texBack;
            _texForeg = texForeg;
            _player = player;
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            Vector2 origin = new Vector2(0f, _texBack.Height/2);

            // Draw background texture
            spriteBatch.Draw(_texBack, Position, null, Color.White, 0f, origin, 1f, SpriteEffects.None, 0f);

            // Draw hp texture
            spriteBatch.Draw(_texForeg, Position, null, Color.White, 0f, origin, 
                new Vector2((1f / _player.MaxHealth) * _player.Health, 1f),
                             SpriteEffects.None, 0f);
        }
    }
}
